<?php
require_once 'RSSReader.php';
require_once 'Untiles.php';
require_once '../model/MyFrunction.php';
class VnexpressReader {
	var $tag = "vnexpress";
	var $data = array ();
	var $title;
	var $desctemp;
	var $link;
	var $date;
	var $temp = array ();
	var $decs = null;
	var $demo = array ();
	var $index=0;
	public function reader() {
		$reader = new RSSReader ();
		$this->data = $reader->reader ( Until::$vnexpress );
		return $this->setData ( $this->data );
	}
	private function setData($data) {
		$check=true;
		foreach ( $data as $item ) {
			$this->index ++;
			foreach ( $item as $value ) {
				$this->title = $value ['title'];
				$this->desctemp = $value ['desc'];
				$this->link = $value ['link'];
				$this->date = $value ['date'];
				$this->temp = split ( "</br>", $this->desctemp );
				// var_dump ( $this->desctemp );
				// exit ();
				if (count ( $this->temp ) >= 2) {
					$this->decs = $this->temp [1];
				} else {
					$this->decs = $this->temp [0];
				}
				
				// array_push ( $this->demo, $this->decs );
				// insert data into database
				$func = new MyFunction ();
				$check = $check and $func->setDataContent ( $this->index, $this->tag, $this->title, $this->decs, $this->link, $this->date );
			}
			// echo "<pre>";
			// print_r ( $this->demo );
			// echo "</pre>";
		}
		return $check;
	}
}

